package com.eqdd.yiqidian.bean;

import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.NonNull;

import com.eqdd.yiqidian.utils.PinYinUtil;

import io.rong.imlib.model.Conversation;

/**
 * Created by lvzhihao on 17-5-2.
 */

public class SelectBean implements Parcelable,Comparable<SelectBean> {
    int layoutType;
    String headImg;
    String content;
    Conversation.ConversationType type;
    String guid;
    boolean isChecked = false;
    boolean isEnable = true;


    public int getLayoutType() {
        return layoutType;
    }

    public void setLayoutType(int layoutType) {
        this.layoutType = layoutType;
    }

    public String getHeadImg() {
        return headImg;
    }

    public void setHeadImg(String headImg) {
        this.headImg = headImg;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public Conversation.ConversationType getType() {
        return type;
    }

    public void setType(Conversation.ConversationType type) {
        this.type = type;
    }

    public String getGuid() {
        return guid;
    }

    public void setGuid(String guid) {
        this.guid = guid;
    }

    public boolean isChecked() {
        return isChecked;
    }

    public void setChecked(boolean checked) {
        isChecked = checked;
    }

    public boolean isEnable() {
        return isEnable;
    }

    public void setEnable(boolean enable) {
        isEnable = enable;
    }

    public SelectBean() {
    }

    @Override
    public int compareTo(@NonNull SelectBean o) {
        return PinYinUtil.head(this.content).compareTo(PinYinUtil.head(o.getContent()));
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(this.layoutType);
        dest.writeString(this.headImg);
        dest.writeString(this.content);
        dest.writeInt(this.type == null ? -1 : this.type.ordinal());
        dest.writeString(this.guid);
        dest.writeByte(this.isChecked ? (byte) 1 : (byte) 0);
        dest.writeByte(this.isEnable ? (byte) 1 : (byte) 0);
    }

    protected SelectBean(Parcel in) {
        this.layoutType = in.readInt();
        this.headImg = in.readString();
        this.content = in.readString();
        int tmpType = in.readInt();
        this.type = tmpType == -1 ? null : Conversation.ConversationType.values()[tmpType];
        this.guid = in.readString();
        this.isChecked = in.readByte() != 0;
        this.isEnable = in.readByte() != 0;
    }

    public static final Creator<SelectBean> CREATOR = new Creator<SelectBean>() {
        @Override
        public SelectBean createFromParcel(Parcel source) {
            return new SelectBean(source);
        }

        @Override
        public SelectBean[] newArray(int size) {
            return new SelectBean[size];
        }
    };
}
